<template>
	<!-- 弹框开始 -->
	<uni-popup ref="popup" type="bottom" :showPopup="true">
		<view class="like">
			<view class="like-tittle">
				<view class="like-tittle-box">
					<image class="like-tittle-img" :src="img" mode="aspectFill"></image>
					<view class="">
						<view class="product-price">￥<text class="plan-price-text">100 </text>/ 个&nbsp;&nbsp;7个</view>
					</view>
				</view>

				<i class="iconfont icon-searchclose" @click="close" />
			</view>
			<view class="like-desc">
				<view class="like-desc-t">
					<view class="like-desc-t-title">
						瓦特
					</view>
					<view class="like-desc-t-box">
						<view :class="['like-desc-t-box-list',index==descIndex?'like-desc-t-box-list-active':'']"
							v-for="item,index in 12" @click="checkFun(index)">
							10号(175*95*115mm)
						</view>
					</view>
				</view>
				<view class="like-desc-b">
					<view class="like-desc-t-title">
						材质硬度等级
					</view>
					<!-- 购物车 -->
					<view class="cart-wrapper">
						<view class="cart-item" v-for="(item, index) in 3" :key="index">
							<view class="cart-item-left">
								<view class="spec-text"><text class="spec-text-sum">x1</text> 商品名称</view>
								<view class="cart-item-left-info">
									<text class="price">¥1</text>
									<text class="sum">库存99663</text>
								</view>
							</view>
							<view class="cart-item-right">
								<view class="stepper">
									<button class="btn minus" :disabled="quantity <= 1"
										@click="changeQuantity(index, -1)">-</button>
									<input class="input" type="number" v-model.number="quantity"
										@blur="validateQuantity(index)" />
									<button class="btn plus" :disabled="quantity >= 10"
										@click="changeQuantity(index, 1)">+</button>
								</view>
							</view>
						</view>
					</view>
				</view>
			</view>
			<!-- 底部操作栏 -->
			<view class="footer">
				<button class="add-cart-btn" @click="addToCart">确认加购</button>
			</view>

		</view>
	</uni-popup>
</template>
<script>
	import {
		mapGetters
	} from 'vuex'
	export default {
		components: {},
		data() {
			return {
				imgUrl: this.$apiFun.imgUrl,
				host: this.$apiFun.host,
				descIndex: 0,
				quantity: 1,
				price: 2,
				img: 'https://qcloud.dpfile.com/pc/_22NoSoft3aE6EJvPPVKZl7azJnSbjQvlobQc1TprekID0bsu-SAtCe9N8iBmkY3.jpg'
			}
		},
		computed: {
			...mapGetters([
				'addrObj'
			]),
		},
		mounted() {},
		methods: {
			open() {
				this.$refs.popup.open()
			},
			close() {

				this.$refs.popup.close()
			},
			checkFun(val) {
				this.descIndex = val
			},
		},
		onReachBottom() {

		},

	}
</script>

<style scoped lang="less">
	// 置顶弹框
	.like {
		width: 100%;
		background-color: #FFFFFF;
		border-radius: 20rpx 20rpx 0 0;
		padding: 40rpx 0 100rpx;
		box-sizing: border-box;
		max-height: 80vh;
		overflow-y: auto;

		.like-tittle {
			border-radius: 20rpx 20rpx 0 0;
			padding: 0 40rpx;
			box-sizing: border-box;
			width: 100%;
			height: 200rpx;
			font-size: 34rpx;
			color: #131313;
			justify-content: space-between;
			display: flex;
			align-items: flex-start;
			background: #fcfcfc;

			.iconfont {
				font-size: 40rpx;
			}

			.like-tittle-box {
				height: 200rpx;
				display: flex;
				align-items: center;

				.like-tittle-img {
					width: 200rpx;
					height: 200rpx;
					border-radius: 10rpx;
				}

				.product-price {
					font-size: 20rpx;
					color: #e64340;
					font-weight: bold;

					.plan-price-text {
						font-size: 40rpx;
						margin: 0 5rpx;

					}
				}
			}

		}

		.like-desc {
			padding: 0 40rpx;
			box-sizing: border-box;
			font-size: 25rpx;
			color: #5c5c5c;
			margin: 30rpx auto 40rpx;
			text-align: left;
			min-height: 300rpx;

			.like-desc-t {
				.like-desc-t-title {
					font-size: 28rpx;
					font-weight: bold;
				}

				.like-desc-t-box {
					margin-top: 25rpx;
					justify-content: space-between;
					display: flex;
					align-items: center;
					flex-wrap: wrap;

					.like-desc-t-box-list {
						width: 300rpx;
						height: 60rpx;
						justify-content: center;
						display: flex;
						align-items: center;
						background-color: #f6f6f6;
						margin-bottom: 22rpx;
						font-size: 24rpx;
						border-radius: 6rpx;
					}

					.like-desc-t-box-list-active {
						background-color: #fd4a21;
						color: white;

					}
				}
			}

			.like-desc-b {
				margin-top: 45rpx;
				.like-desc-t-title {
					font-size: 28rpx;
					font-weight: bold;
				}

				.cart-wrapper {
					margin: 30rpx 0 120rpx;

					.cart-item {
						background: white;
						padding: 24rpx;
						margin-bottom: 20rpx;
						border-radius: 16rpx;
						display: flex;
						justify-content: space-between;

						.cart-item-left {
							.spec-text {
								display: block;
								font-size: 26rpx;
								color: #333;
								margin-bottom: 12rpx;
								.spec-text-sum{
									margin-right: 5rpx;
									padding: 2rpx 8rpx;
									border-radius: 15rpx;
									color: #ffffff;
									background: #f94d1b;
								}
							}

							.cart-item-left-info {
								display: flex;
								align-items: center;
								color: #9b999a;
									font-size: 20rpx;
								.price {
									padding-right: 10rpx;
									margin-right: 10rpx;
									border-right: 1rpx solid #9b999a;
									height:14rpx;
									line-height: 14rpx;
								}
								.sum{
									
								}
							}
						}

						.cart-item-right {
							text-align: right;

							.stepper {
								display: flex;
								align-items: center;
								margin-bottom: 12rpx;

								.btn {
									width: 50rpx;
									height: 50rpx;
									line-height: 46rpx;
									padding: 0;
									border: 2rpx solid #ddd;
									border-radius: 8rpx;
									font-size: 32rpx;
									background: white;

									&.disabled {
										opacity: 0.6;
									}
								}

								.input {
									width: 80rpx;
									height: 50rpx;
									margin: 0 12rpx;
									text-align: center;
									font-size: 28rpx;
									border: 2rpx solid #ddd;
									border-radius: 8rpx;
								}
							}

							.total {
								font-size: 28rpx;
								color: #ff4444;
							}
						}
					}
				}



			}
		}
	}

	.footer {
		position: fixed;
		bottom: 0;
		left: 0;
		right: 0;
		background: #fff;
		padding: 20rpx;
		box-shadow: 0 -2rpx 10rpx rgba(0, 0, 0, 0.1);

		.add-cart-btn {
			background: #ff5000;
			color: #fff;
			border-radius: 50rpx;
		}
	}
</style>